﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Infrastructure.Data.UnitOfWork;
using Domaine.Entity;
namespace Infrastructure.Data.MembershipModule.test 
{
    public class MembershipUnitOfWorkInitializer : DropCreateDatabaseAlways<MembershipUnitOfWork>
    {

        protected override void Seed(MembershipUnitOfWork unitOfWork)
        {
            AspApplication app = new AspApplication()
            {
                ApplicationID=Guid.NewGuid(),
                ApplicationName="/",
                LoweredApplicationName="/",
                
            };
            Membership member = new Membership()
            {
                ApplicationID=app.ApplicationID,
                CreateDate = DateTime.UtcNow,
                Comment="",
                IsApproved=true,
                IsLockedOut=false,
                Email="nnnnn@nbv.com",
                Password="11447",
                PasswordSalt="478541254ki",
                LastLockoutDate= DateTime.UtcNow,
                LastLoginDate = DateTime.UtcNow,
                LastPasswordChangedDate = DateTime.UtcNow,
                LoweredEmail = "nnnnn@nbv.com",
                PasswordAnswer="",
                PasswordFormat=System.Web.Security.MembershipPasswordFormat.Clear,
                PasswordQuestion="",
                FailedPasswordAnswerAttemptCount=0,
                FailedPasswordAnswerAttemptWindowStart=DateTime.UtcNow,
                FailedPasswordAttemptCount=0,
                MobilePIN="0101",
                FailedPasswordAttemptWindowStart = DateTime.UtcNow,
            };
            User user = new User()
            {
                UserID=new Guid("0343C0B0-7C40-444A-B044-B463F36A1A1F"),
                Application=app,
                Membership=member,
                UserName="test",
                LoweredUserName="test",
                LastActivityDate = DateTime.UtcNow,
                IsAnonymous=false
            };
            member.User = user;
            member.UserID = user.UserID;
            unitOfWork.Users.Add(user);
            unitOfWork.Memberships.Add(member);
            unitOfWork.AspApplications.Add(app);
            unitOfWork.Commit();


        }
    }
}
